/**
 * Created by sky on 16/1/18.
 */
    //@Deprecated
var API = require('API');
var insurance = "<div class='insurance-types-menu' ng-show='insurance_types_isShow' ng-click='insurance_types_isShow = !insurance_types_isShow'>" +
    "<div class='container-fluid common-cover-main' ng-click='$event.stopPropagation()'>" +
    "<div class='row common-header'><div class='col-xs-12'>选择保险品种</div></div>" +
    "<div class='row insurance-types-row' ng-repeat='item in insurance_types' ng-if='item.type!=insurance_types[$index-1].type'>" +
    "<div class='col-md-2'>{{item.type}}</div><div class='col-md-10' >" +
    "<select ng-model='' ng-options='_item.name for _item in insurance_types|filter:item.type'></select></div></div> </div></div>";
module.exports = function(){
    return {
        restrict: 'E',
        scope: {
            user: "=user"
        },
        template: '',
        replace: true,
        controller: ['$scope', '$element', function ($scope, $element) {
            $scope.data = [];
            $scope.show = false;
            $scope.user_name_filter = "";
            $element.children('input').click(function () {
                if ($scope.show == false)
                    API.user.brief(function (list) {
                        $scope.$apply(function () {
                            $scope.data = list;
                            $scope.show = true;
                        });
                    });
                else $scope.$apply(function () {
                    $scope.show = false;
                })
            });
            $scope.submit = function (user) {
                $scope.user = user;
                $element.children('input').val(user.name);
                $scope.show = false;
            };

        }]
    }
};